<template>
  <div>
      <div>
        <button @click="goBack">返回</button>
        <div>
          我是详情页 --  
        </div>
        <h3>
          {{ obj.title }}
        </h3>
      </div>
  </div>
</template>

<script>
import axios from 'axios'
// 路由传参
export default {
  data() {
    return {
      obj: {}
    }
  },
  created() {
    axios.get('/getDetail', {
      params: {
        id: this.$route.query.id
      }
    }).then(res => {
      this.obj = res.data
      console.log(res.data)
    })
  },
  methods: {
    goBack() {
      // this.$router 
      // this.$router.back()  返回上一层
      // this.$router.back()
      // this.$router.go(-1)
      this.$router.go(-1)
      // console.log(this.$router)
    }
  }
}
</script>

<style>

</style>